package com.biodiv.datamapper.factory;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;

/**
 * @author: tianquan
 * @date: 2025-05-30  10:08
 * @description: mapper代理类
 */
public class MapperProxy implements InvocationHandler {

    private final MapperBoost mapperBoost = new MapperBoost();
    private static final List<String> CLASS_LIST = Arrays.stream(Object.class.getMethods()).map(Method::getName).toList();

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) {
        return mapperBoost.invoke(method, args);
    }

    public class MapperBoost {

        public Object invoke(Method method, Object[] args) {
            String name = method.getName();
            if (CLASS_LIST.contains(name)) {
                return this.toString();
            }

            // 执行sql
            System.out.println("执行" + name);

            return null;
        }

    }


}
